<?php
defined('IN_XLP') or die('Access Denied');
$Document = array(
    'pageid'   => 'forum-add', //页面标示
    'pagename' => '添加论坛系统消息', //当前页面名称
    'mycss'    => array('../jquery-ui/css/smoothness/jquery-ui-1.10.0.custom.min'), //加载的css样式表
    'myjs'     => array(), //加载的js脚本
    'footerjs' => array(
        '../jquery-ui/js/jquery-ui-1.10.0.custom.min',
        '../jquery-ui/js/jquery-ui-timepicker-addon',
    ),
    'head'     => true, //加载头部文件
);

include getTpl('header', 'public');
?>
<style>
</style>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
<section id="content">
    <section class="main padder">
        <div class="clearfix">
            <h4><i class="fa fa-edit"></i>新增论坛系统消息</h4>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <section class="panel">
                    <div class="panel-body">
                        <form class="form-horizontal" id="msgAddForm" method="post" autocomplete="off">
                            
                            <div class="form-group">
                                <label class="col-sm-1 control-label">消息标题</label>
                                <div class="col-sm-2">
                                    <input type="text" name="title" id="title" placeholder="消息标题" class="form-control" />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label">调用模块</label>
                                <div class="col-sm-2">
                                    <input type="text" name="mode" id="mode" placeholder="调用模块" class="form-control" value="forum" />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label">相关参数</label>
                                <div class="col-sm-2">
                                    <input type="text" name="para" id="para" placeholder="相关参数" class="form-control" value="fid="/>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label">发布时间</label>
                                <div class="col-sm-2">
                                    <input type="text" name="time" id="time" placeholder="发布时间" class="form-control" />
                                </div>
                            </div>


                            <div class="form-group pt7">
                                <div class="col-sm-9 col-lg-offset-1">
                                    <div class="col-sm-1">
                                        <button type="submit" id="sub-ok" data-loading-text="正在提交..." class="btn btn-primary">保存</button>
                                    </div>
                                    <button type="button" class="btn btn-white">取消</button>
                                </div>
                            </div>

                        </form>
                    </div>
                </section>
            </div>
        </div>
    </section>
</section>
<!--/ content --> 
<!--主体 结束-->
<script>
var forum_url = "<?php echo U('app/forum') ?>";

$(function(){

    $('#time').datetimepicker();

    $('#msgAddForm').submit(function(){

        if( $.trim($('#title').val()) == '' ) {
            Msg.error('请输入消息标题');
            resetSubmit("#sub-ok",'提交');
            return false;
        }
        if( $.trim($('#mode').val()) == '' ) {
            Msg.error('请输入调用模块');
            resetSubmit("#sub-ok",'提交');
            return false;
        }
        if( $.trim($('#para').val()) == '' ) {
            Msg.error('请输入相关参数');
            resetSubmit("#sub-ok",'提交');
            return false;
        }
        if( $.trim($('#time').val()) == '' ) {
            Msg.error('请选择发布时间');
            resetSubmit("#sub-ok",'提交');
            return false;
        }

        Msg.loading();
        $.post('<?php echo U("app/forum_add"); ?>', $(this).serialize(), function(result){
            Msg.hide();
            resetSubmit("#sub-ok",'提交');
            if(result.status == 1) {
                // Msg.ok(result.info);
                self.location.href = forum_url;
            } else {
                Msg.error(result.info);
            }
        }, 'JSON');
        return false;
    });
});
</script>
<?php include getTpl('footer', 'public'); ?>